package net.neiquan.applibrary.utils;

import android.util.Log;

/**
 * 作者 : dyj
 * 时间 : 2016/4/26.
 */
public class LogC {
    private static boolean isPrintLog = true;
    private static String TAG = "---LogC-->";

    public static void e(String msg) {
        if (msg != null)
            if (isPrintLog) {
                int index = 0;
                int maxLength = 4000;
                String sub;
                while (index < msg.length()) {
                    // java的字符不允许指定超过总的长度end
                    if (msg.length() <= index + maxLength) {
                        sub = msg.substring(index);
                    } else {
                        try {
                            sub = msg.substring(index, maxLength);
                        } catch (Exception e) {
                            e.printStackTrace();
                            return;
                        }
                    }
                    index += maxLength;
                    Log.e(TAG, sub);
                }
            }
    }

    public static void i(String tag, String msg) {
        if (msg != null)
            if (isPrintLog) {
                int index = 0;
                int maxLength = 4000;
                String sub;
                while (index < msg.length()) {
                    // java的字符不允许指定超过总的长度end
                    if (msg.length() <= index + maxLength) {
                        sub = msg.substring(index);
                    } else {
                        try {
                            sub = msg.substring(index, maxLength);
                        } catch (Exception e) {
                            e.printStackTrace();
                            return;
                        }
                    }
                    index += maxLength;
                    Log.e(TAG + tag, sub);
                }
            }
    }

    public static void i(String msg) {
        if (msg != null)
            if (isPrintLog) {
                int index = 0;
                int maxLength = 4000;
                String sub;
                while (index < msg.length()) {
                    // java的字符不允许指定超过总的长度end
                    if (msg.length() <= index + maxLength) {
                        sub = msg.substring(index);
                    } else {
                        try {
                            sub = msg.substring(index, maxLength);
                        } catch (Exception e) {
                            e.printStackTrace();
                            return;
                        }
                    }
                    index += maxLength;
                    Log.i(TAG, sub);
                }
            }
    }

    public static void e(String tag, String msg) {
        if (msg != null)
            if (isPrintLog) {
                int index = 0;
                int maxLength = 4000;
                String sub;
                while (index < msg.length()) {
                    // java的字符不允许指定超过总的长度end
                    if (msg.length() <= index + maxLength) {
                        sub = msg.substring(index);
                    } else {
                        try {
                            sub = msg.substring(index, maxLength);
                        } catch (Exception e) {
                            e.printStackTrace();
                            return;
                        }
                        ;
                    }
                    index += maxLength;
                    Log.e(TAG + tag, sub);
                }
            }
    }

    public static void w(String tag, String msg) {
        if (msg != null)
            if (isPrintLog) {
                int index = 0;
                int maxLength = 4000;
                String sub;
                while (index < msg.length()) {
                    // java的字符不允许指定超过总的长度end
                    if (msg.length() <= index + maxLength) {
                        sub = msg.substring(index);
                    } else {
                        try {
                            sub = msg.substring(index, maxLength);
                        } catch (Exception e) {
                            e.printStackTrace();
                            return;
                        }
                    }
                    index += maxLength;
                    Log.w(TAG + tag, sub);
                }
            }
    }

    public static void d(String tag, String msg) {
        if (msg != null) {

        }
        if (isPrintLog) {
            int index = 0;
            int maxLength = 4000;
            String sub;
            while (index < msg.length()) {
                // java的字符不允许指定超过总的长度end
                if (msg.length() <= index + maxLength) {
                    sub = msg.substring(index);
                } else {
                    try {
                        sub = msg.substring(index, maxLength);
                    } catch (Exception e) {
                        e.printStackTrace();
                        return;
                    }
                }
                index += maxLength;
                Log.d(TAG + tag, sub);
            }
        }
    }
}
